import Vue from 'vue'

// 将首字母变成大写
function changeStr (str) {
  return str.charAt(0).toUpperCase() + str.slice(1)
}

const requireComponent = require.context('.', false, /\.vue$/)

requireComponent.keys().forEach(fileName => {
  const config = requireComponent(fileName)
  // 去掉文件名的头尾
  const componentName = changeStr(fileName.replace(/^\.\//, '').replace(/\.vue$/, ''))
  Vue.component(componentName, config.default || config)
})
